date
if [ -e /dev/tcaicard0 ];then
        AICARD_NUM=`ls /dev/tcaicard* | wc -l`
else
        echo "No card !"
        exit 1
fi


PSY_AICARD_NUM_1=`expr $AICARD_NUM / 3`
let PSY_AICARD_NUM=${PSY_AICARD_NUM_1}-1

SAVEDLOG=$1/3COREFUNC

CUR_PATH=`pwd`
log_file=$SAVEDLOG/3CORE_PCIE_FUNC.log_all

mkdir -p $SAVEDLOG
if [ -e $log_file ];then
    rm -rf $log_file
fi

echo $log_file

touch $log_file


for card_id in `seq 0 ${PSY_AICARD_NUM}`
do
    sh 3CORE_PCIE_hbm.sh $card_id $SAVEDLOG --card_id_$card_id | tee -a $log_file &
done


wait

result=$(cat $log_file | grep  'FAILED')
length=$(expr length "$result")
if [[ length -gt 0 ]];
then
        echo -e "CARD_FUNC TEST RESULT: \E[31m [FAILED] \E[0m" | tee -a $log_file
else
        echo -e "CARD_FUNC TEST RESULT: \E[32m [PASS] \E[0m" | tee -a $log_file
fi


echo "function finished"
